package com.xintoucloud.gsv.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import com.xintoucloud.gsv.entity.SuperVision;

public interface SuperVisionMapper {
	/**
	 * 保存一条督办信息
	 * @param superVision
	 */
	@Insert("INSERT INTO t_supervision(svTitle,svContent,startTime,confirmTime,endTime,sendLeader,replices,sid,did,state) values(#{svTitle},#{svContent},"
			+ "#{startTime},#{confirmTime},#{endTime},#{sendLeader},#{replices},#{supervisionType.sid},#{dept.did},#{superVisionState.stid})")
	void save(SuperVision superVision);
	/**
	 * 查询所有的督办信息
	 * @return
	 */
	@Select("select * from t_supervision")
	@Results({
		@Result(property="supervisionType",column="sid",one=@One(select="com.xintoucloud.gsv.mapper.SupervisionTypeMapper.getSupervisionType")),
		@Result(property="dept",column="did",one=@One(select="com.xintoucloud.gsv.mapper.DeptMapper.getDept")),
		@Result(property="superVisionState",column="state",one=@One(select="com.xintoucloud.gsv.mapper.SuperVisionStateMapper.getSuperVisionState"))
	})
	List<SuperVision> list();
	/**
	 * 分页查询
	 * @return
	 */
	@Select("select * from t_supervision limit #{pageIndex},#{size}")
	@Results({
		@Result(property="supervisionType",column="sid",one=@One(select="com.xintoucloud.gsv.mapper.SupervisionTypeMapper.getSupervisionType")),
		@Result(property="dept",column="did",one=@One(select="com.xintoucloud.gsv.mapper.DeptMapper.getDept")),
		@Result(property="superVisionState",column="state",one=@One(select="com.xintoucloud.gsv.mapper.SuperVisionStateMapper.getSuperVisionState"))
	})
	List<SuperVision> listPage(@Param("pageIndex")int pageIndex,@Param("size")int size);
	/**
	 * 查询总条数
	 * @return
	 */
	@Select("select count(*) from t_supervision")
	long count();
}
